/**
 * 与City相关的API接口定义
 */
import axios from './config'
import { AxiosPromise } from 'axios'
import {Icity, IPlace} from './config/responseType'

/**
 * 获取首页默认地址
 */
// 传入参数类型
interface reqCityArgInterface {
    type:string,
}
export const reqGuessCity = (params: reqCityArgInterface): AxiosPromise<Icity> => {
    return axios.request({
        url:  'http://wods.plus:8001/v1/cities',
        params: params,
        method: 'get',
    })
}

/**
 * 获取首页城市
 */
export const reqCity = (params: reqCityArgInterface): AxiosPromise<Icity[]> => {
    return axios.request({
        url:  '/v1/cities',
        params: params,
        method: 'get',
    })
}

/**
 * 根据ID查找对应的城市名
 */
// 传入参数的类型
interface reqCurrentCityArgInterface {
    id:number,
}
export const reqCurrentCity =
    (params:reqCurrentCityArgInterface): AxiosPromise<Icity[]> => {
    return axios.request({
        url:  '/v1/cities',
        params: params,
        method: 'get',
    })
}
/**
 * 根据经纬度查找对应的城市名
 */
export const reqMsiteAddress = (geohash :string | (string | null)[] ):AxiosPromise<IPlace> => {
    return axios.request({
        url:'/v2/pois/' + geohash,
        method:'GET'
    })
}
